<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import=" vn.edu.ptithcm.helper.CKEditorConfigHelper" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message  code="pim"/> - <spring:message  code="homepage.project"/>&nbsp;
       <c:out value="${bean.project.name}"></c:out> - <spring:message  code="project.update.task" />&nbsp;#${task.code}</title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/uploadify.css" rel="stylesheet" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.json.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.uploadify.v2.1.4.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/swfobject.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/AC_OETags.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/task-script.jsp" %>
<style type="text/css">
input ,select {
	width: 100%;
}
</style>
</head>
<body>
<c:if test="${bean.isSigned}">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
    <jsp:include page="include/common/topMenuHome.jsp" />
</div>
<div class="main-content">
<form:form action="" method="post" commandName="task" name="updateTask" acceptCharset="UTF-8" enctype="multipart/form-data">	   		  
<div>
	<div class="v-row">
		<div class="v-row-left" style="margin-left: 10px;">
			<span class="v-title">
				<spring:message  code="project.update.task" />
			</span>
		</div>
		<c:set value="tasks.htm?pnum=${bean.project.number}" var="url"/>  
		<div style="float: right;">
			<a href='<c:out value="${url}" />' style="padding-right: 10px;color: blue;text-decoration:none;"> 
				[<spring:message code="back.to.project.homepage" />]</a>
		</div>			
	</div>
	
	<div class="v-row" id="v-global-message">	   
	    <c:if test="${editOK}">
	      	<span class="v-global-success-message v-row">
	      	    <span><spring:message  code="handle.edit.task.success" /></span>
	      	</span>
	    </c:if>
	    <c:if test="${errorCode == 1}">
	      	<span class="v-global-error-message v-row">
	      	    <span><spring:message  code="handle.edit.task.error.1" /></span>
	      	</span>
	    </c:if>	
	    <c:if test="${errorCode == 2}">
	      	<span class="v-global-error-message v-row">
	      	    <span><spring:message  code="handle.edit.task.error.2" /></span>
	      	</span>
	    </c:if>		    
	    <c:if test="${isOptimisticLocking}">
	      	<span class="v-global-error-message v-row">
	      	    <span><spring:message  code="handle.edit.task.optimistic.locking" /></span>
	      	</span>
	    </c:if>
	</div>	
	<div class="v-row">	
	<table cellspacing="1" class="width100 v-table">
		<tbody>		
		<tr class="v-table-header">
			<td width="15%"><spring:message  code="title.task.id" /></td>
			<td width="20%"><spring:message  code="title.required.task.category" /></td>
			<td width="20%"><spring:message  code="title.required.task.severity" /></td>
			<td width="15%"><spring:message  code="title.task.date.submitted" /></td>
			<td width="15%"><spring:message  code="title.task.date.last.update" /></td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><c:out value="${task.code}" /></td>
			<td>
                 <form:select path="taskCategory.categoryid">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="category" items="${bean.categories}">
                         <option value="${category.categoryid}"
                               <c:if test="${task.taskCategory.categoryid == category.categoryid}">
                                     selected="selected"
                               </c:if> >
                               <c:out value="${category.name}" />
                         </option>
                        </c:forEach>
                  </form:select>				    				 
				  <br/>
				  <form:errors path="taskCategory" cssClass="v-error-message" />			
			</td>		
			<td>
				<form:select path="taskSeverity.severityid">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="severity" items="${bean.severities}">
                         <option value="${severity.severityid}"
                               <c:if test="${task.taskSeverity.severityid == severity.severityid}">
                                     selected="selected"</c:if>>
                               <c:out value="${severity.name}" />
                         </option>
                        </c:forEach>
                 </form:select>				    			
				<br/>
				<form:errors path="taskSeverity" cssClass="v-error-message" />	
			</td>			
			<td><fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${task.createdtime}" /></td>			
			<td><fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${task.lastchanged}" /></td>		
		</tr>
				
		<tr class="v-table-row-1">
			<td><spring:message code="task.reporter" /></td>
			<td><c:out value="${task.reporter}" /></td>
			<td colspan="4">&nbsp;</td>
		 </tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.monitoredby" /></td>
			<td>
			    <form:select path="monitoredby">
                        <option value=""><spring:message code="please.choice" /></option>
                        <c:forEach var="efip" items="${bean.efips}">
                         <option value="${efip.employee.visa}"
                               <c:if test="${task.monitoredby == efip.employee.visa}">
                                     selected="selected"</c:if>>
                               <c:out value="${efip.employee.visa}" />
                         </option>
                        </c:forEach>
                 </form:select>	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.assignedto" /></td>
			<td>
			    <form:select path="assignedto">
                        <option value=""><spring:message code="please.choice" /></option>
                        <c:forEach var="efip" items="${bean.efips}">
                         <option value="${efip.employee.visa}"
                               <c:if test="${task.assignedto == efip.employee.visa}">
                                     selected="selected"</c:if>>
                               <c:out value="${efip.employee.visa}" />
                         </option>
                        </c:forEach>
                 </form:select>	
                 <br/>
                 <form:errors path="assignedto" cssClass="v-error-message" />	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="title.required.task.priority" /></td>
			<td>
				<form:select path="taskPriority.priorityid">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="priority" items="${bean.priorities}">
                         <option value="${priority.priorityid}"
                               <c:if test="${task.taskPriority.priorityid == priority.priorityid}">selected="selected"</c:if>>
                               <c:out value="${priority.name}" />
                         </option>
                        </c:forEach>
                 </form:select>				    
				 <br/>
				 <form:errors path="taskPriority" cssClass="v-error-message" />	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="title.required.task.status" /></td>
			<td>
				<form:select path="taskStatus.statusid">                      
                        <c:forEach var="status" items="${bean.statuses}">
                         <option value="${status.statusid}"
                               <c:if test="${task.taskStatus.statusid == status.statusid}">selected="selected"</c:if>>
                               <c:out value="${status.name}" />
                         </option>
                        </c:forEach>
                 </form:select>	
                 <br/>
				  <form:errors path="taskStatus" cssClass="v-error-message" />					    				
            </td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="title.required.task.summary" /></td>
			<td colspan="5">
			    <form:input path="summary" maxlength="200" cssStyle="width:803px;height:30px;"/>
			     <br/>
				<form:errors path="summary" cssClass="v-error-message" />	
			</td>
		</tr>
	
		<tr class="v-table-row-1">
			<td><spring:message code="title.required.task.description" /></td>
			<td colspan="5">
			    <form:textarea cols="98" rows="8" path="description"/>	
			    <br/>
				<form:errors path="description" cssClass="v-error-message" />		
			</td>
		</tr>		
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.additionalinformation" /></td>
			<td colspan="5">
			    <form:textarea cols="98" rows="8" path="additionalinformation"/>	
			</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.percent.completed" /></td>
			<td>
			     <form:input  maxlength="4" path="percentcomplete" onkeypress="return isDecimal(event)"  />			   
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.actual.hours" /></td>
			<td>
			    <form:input  maxlength="3" path="actualtime" onkeypress="return isDecimal(event)"  />	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.estimate.hours" /></td>
			<td>
			    <form:input  maxlength="3" path="estimatetime" onkeypress="return isDecimal(event)"  />	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
								
		<tr class="v-table-row-0">
			<td><spring:message code="title.required.task.starttime"/></td>
			<td>
		         <form:input path="starttime" cssStyle="width:92%;"/>
		         <br/>
		         <form:errors path="starttime" cssClass="v-error-message" />	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="title.task.endtime"/></td>
			<td>
		         <form:input path="endtime" cssStyle="width:92%;"/>
		         <br/>
		         <form:errors path="endtime" cssClass="v-error-message" />	
			</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.phase" /></td>
			<td>
			    <form:select path="phase">
		                <form:option value=""><spring:message  code="please.choice" /></form:option>
                        <form:options items="${bean.phases}" itemLabel="name" itemValue="name"/>
		        </form:select>		
			</td>
			<td colspan="4">&nbsp;</td>	
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.note" /></td>
			<td colspan="5">
				<form:textarea cols="97" rows="8" path="note" />	
			</td>
		</tr>
    </tbody>
    </table>
	</div>	
	<div class="v-row v-row-0">
		<div class="v-row-left">
			<span>
		     	<spring:message code="task.attachedfiles" />
			</span>
		</div>			
		<div class="v-row-right" style=" width: 85%;">
		    <input name="fileUploads" id="fileUploads" type="file" size="100" />
		</div>				
	</div>			                   			
	<div class="v-row v-row-1">	  
		<div class="v-row-center">
			<span>
			<input type="button" onclick="startUpload('fileUploads');" class="bt-form" 
			       value="<spring:message code="button.update" />"/>
			</span>				
			<span>
			<input type="button" class="bt-form" value="<spring:message code="button.cancel"/>" 
					onclick="cancel('<c:out value='${bean.returnToFullPageURL }'/>')"/>
			</span>
		</div>
	</div>
	<div id="nosupportFlash" class="v-row v-row-1" style="display: none;">
        <h4>Your browser don't support to the flash now! Please choose the other browser.</h4>
    </div> 					
</div>
<input type="hidden" name="cmd" value="updateTask"/>
<input type="hidden" name="_attachedfiles"/>
<input type="hidden" name="returnToFullPageURL" value="${bean.returnToFullPageURL}"/>
<input type="hidden" name="pnum" value="${bean.project.number}"/>
</form:form>	
</div>	
</div>
</div>
<div class="footer">
	<jsp:include page="include/common/footer.jsp" />
</div>
</div>
<ckeditor:replace basePath="/ckeditor/" replace="description" config="<%= CKEditorConfigHelper.createConfig(803) %>"/>
<ckeditor:replace basePath="/ckeditor/" replace="additionalinformation" config="<%= CKEditorConfigHelper.createConfig(803) %>"/>
<ckeditor:replace basePath="/ckeditor/" replace="note" config="<%= CKEditorConfigHelper.createConfig(803) %>"/>
</c:if>
</body>
</html>